<?php
if (!defined('access')) {
    echo 'You cannot access this file directly.';
    exit();
}
$file = htmlspecialchars_decode($this->category_title);
        echo '<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">

<bookmark>Subtitle selection</bookmark>
<mediaDisplay
	name=onePartView
	itemPerPage=6
	viewAreaXPC=20
	viewAreaYPC=15
	viewAreaWidthPC=70
	viewAreaHeightPC=70
	itemXPC=10
	itemYPC=37.5
	itemWidthPC=80
	itemHeightPC=8
	itemImageXPC=10
	itemImageYPC=37.5
	itemImageWidthPC=80
	itemImageHeightPC=8
	imageFocus=""
	imageUnFocus=""
	sideColorRight=-1:-1:-1
	sideColorLeft=-1:-1:-1
	sideColorTop=-1:-1:-1
	sideColorBottom=-1:-1:-1
	backgroundColor=-1:-1:-1
	focusBorderColor=-1:-1:-1
	unFocusBorderColor=-1:-1:-1
	itemBackgroundColor=-1:-1:-1
	showHeader="no"
	showDefaultInfo="no"
	rollItems="no"
	forceRedrawItems="yes"
>
<idleImage>image/POPUP_LOADING_01.png</idleImage>
        <idleImage>image/POPUP_LOADING_02.png</idleImage>
        <idleImage>image/POPUP_LOADING_03.png</idleImage>
        <idleImage>image/POPUP_LOADING_04.png</idleImage>
        <idleImage>image/POPUP_LOADING_05.png</idleImage>
        <idleImage>image/POPUP_LOADING_06.png</idleImage>
        <idleImage>image/POPUP_LOADING_07.png</idleImage>
        <idleImage>image/POPUP_LOADING_08.png</idleImage>
<text redraw=yes offsetXPC=5 offsetYPC=5 widthPC=90 heightPC=31.7 fontSize=14 align=center >
	Select subtitle
</text>
<itemDisplay>
	<!-- clear background -->
	<image offsetXPC=0 offsetYPC=0 widthPC=100 heightPC=100 useBackgroundSurface="yes"/>
	<!-- draw foreground -->
	<image offsetXPC=0 offsetYPC=0 widthPC=100 heightPC=100>
		<script>
			image = "";
			queryIndex = getQueryItemIndex();
			focusIndex = getFocusItemIndex();
			if (queryIndex == focusIndex) {
				image = "./setup_menu/image/UI_Settings_Banner.png";
			}
			image;
		</script>
	</image>
	<text offsetXPC=5 offsetYPC=5 widthPC=90 heightPC=90 align=left fontSize=14 backgroundColor=-1:-1:-1 foregroundColor=255:255:255>
		<script>
			getItemInfo("title");
		</script>
	</text>
</itemDisplay>
</mediaDisplay>
<channel>
<title>Select subtitle</title>
<item>
<title>Turn subtitle off</title>
<onClick>
setReturnString("sub_off");
postMessage("return");
</onClick>
</item>';
        $dirname = pathinfo($file);
        $source = $dirname['dirname'];
        $escapedBracketPath = str_replace('[', '\[', $source);
        $escapedBracketPath = str_replace(']', '\]', $escapedBracketPath);
	$escapedBracketPath = str_replace('\[', '[[]', $escapedBracketPath);
	$escapedBracketPath = str_replace('\]', '[]]', $escapedBracketPath);
        foreach (array_merge(glob($escapedBracketPath . "/*.srt"),glob($escapedBracketPath . "/*.sub") ) as $subtitle) {
            $subs = pathinfo($subtitle);
            $name = $subs['filename'];
        echo '<item>
	<title>' . htmlspecialchars($name) . '.'. $subs['extension']. '</title>
        <onClick>
        dummy=getURL("http://127.0.0.1/Jukebox/srjg.php?srtxml,' . urlencode($subtitle) . '");
        setReturnString("'. $subtitle .'");
        postMessage("return");
        </onClick>
	</item>';
}
        echo '</channel>
</rss>';
?>
